#include <stdio.h>

int narcissistic(int number);
void PrintN(int m, int n);

int main()
{
    int m, n;

    scanf("%d %d", &m, &n);
    if (narcissistic(m))
        printf("%d is a narcissistic number\n", m);
    PrintN(m, n);
    if (narcissistic(n))
        printf("%d is a narcissistic number\n", n);

    return 0;
}

#include <math.h>
int narcissistic(int number)
{
    //get the length of number
    int length = 0;
    int temp = number;
    while (temp)
    {
        length++;
        temp /= 10;
    }
    int sum = 0;
    temp = number;
    do
    {
        int per = temp % 10;
        temp /= 10;
        sum += pow(per, length);
    } while (temp);

    if (sum == number)
        return 1;
    else
        return 0;
}

void PrintN(int m, int n){
    for (int i = m + 1; i < n; i++)
    {
        if(narcissistic(i))
            printf("%d\n",i);
    }
    
}
